<% form_tag :controller => 'customer', :action => 'list_customers', :method => 'get' do %>
		<%= text_field_tag :search, params[:search], :id => 'search_field' %>
		<%= submit_tag "Search", :name => nil %>
		<%= link_to_function "Clear", "$('search_field').clear()" %>
<% end %>
<table id="customer_table" class="tablesorter">
<thead>
    <tr>
      <th>
        Customer name
      </th>
      <th>
        Student ID
      </th>
      <th>
      	Phone
      </th>
      <th>
      	Email
      </th>
    </tr>
</thead>
<tbody>
<% if @customers != nil %>
<% for customer in @customers %>
  <tr>
    <td>
	  <%= h(customer.first_name) + " " + h(customer.last_name) %>
	</td><td>
	  stu<%= h(customer.studentid) %>
	</td><td>
	  <% if customer.phone && customer.phone.length == 10 %>
	     (<%= h(customer.phone[0..2]) %>)&nbsp;&nbsp;<%= h(customer.phone[3..5]) %>&nbsp;-&nbsp;<%= h(customer.phone[6..9]) %>
	  <% else %>
	    <%= h(customer.phone) %>
	  <% end %>
	</td><td>
	  <a href="mailto:<%= h(customer.email) %>"><%= h(customer.email) %></a>
	</td>
	<td style="text-align:center">
	  <%= link_to "Edit", {:action => "edit_customer", :id => customer} %>	  
    </td>
	<% if @employee.is_manager %>
	<td style="text-align:center">
      <%= link_to "Delete", {:action => "delete_customer", :id => customer}, {:method => :post, :confirm => "Confirm removal of #{customer.first_name} #{customer.last_name}"} %>      
    </td>
	<%end%>
</tr>
<% end %>
<%else%>
<tr><td>There are no customers</td></tr>
<%end%>
</tbody>
</table>
<script type="text/javascript">
    $("#employee_table").tablesorter();
</script>

